
svyset [pweight=weight_ftf], strata(strata_ftf)

gen face2face=mode
recode face2face 1=1 2=0
label var face2face "In-Person Interviews"
tab face2face

*****Demographics

gen white=dem_raceeth
replace white=. if white <0	
recode white 1=1 2=0 3=0 4=0
tab white


gen female=gender_respondent
replace female=0 if female==1
replace female=1 if female==2
tab female 

gen age=dem_age_r_x
recode age -2=.
label var age "Respondent Age"
tab age

gen educ=dem_edugroup
replace educ=. if educ<0
gen educ2=(educ-1)/4
label var educ2 "Education Recoded 0-1"
tab educ2

gen income=incgroup_prepost
replace income=. if income <0
foreach v of varlist income {
	su `v', meanonly
	replace `v'= (`v' - r(min))/(r(max) - r(min))
}

gen ownhome=dem3_ownhome
replace ownhome=. if ownhome<0
recode ownhome 1=1 2=0 5=.
label var ownhome "Respondent Owns Their Home"
tab ownhome

gen region=sample_state 
encode region, gen(south_id)
tab south_id
tab south_id, nolabel
replace south_id=0 if south_id==1
replace south_id=1 if south_id==2
replace south_id=1 if south_id==3
replace south_id=1 if south_id==10
replace south_id=1 if south_id==11
replace south_id=1 if south_id==19
replace south_id=1 if south_id==26
replace south_id=1 if south_id==28
replace south_id=1 if south_id==41
replace south_id=1 if south_id==43
replace south_id=1 if south_id==44
replace south_id=1 if south_id==46
replace south_id=0 if south_id>1
tab south_id

gen south=south_id
label var south "Eleven States of the Old Confederacy"
tab south

tab ofcrec_speaker_correct
	gen speaker=ofcrec_speaker_correct
	replace speaker=. if speaker<0
	tab speaker
	
	*Office recognition: VP
	tab ofcrec_vp_correct
	gen vicepres=ofcrec_vp_correct
	replace vicepres=. if vicepres<0
	tab vicepres

	*Office recognition: UK Prime Minister
	tab ofcrec_pmuk_correct
	gen ukprime=ofcrec_pmuk_correct
	replace ukprime=. if ukprime<0
	tab ukprime
	
	*Office recognition: Chief Justice
	tab ofcrec_cj_correct
	gen chiefjustice=ofcrec_cj_correct
	replace chiefjustice=. if chiefjustice<0
	tab chiefjustice
	
	gen polinfo=(speaker+vicepres+ukprime+chiefjustice)/4
	tab polinfo
	label var polinfo "Political Information Scale"
tab polinfo

gen favors=resent_workway
recode favors -9 -8 -7 -6=. 1=1 2=.75 3=.5 4=.25 5=0
gen slavery=resent_slavery
recode slavery -9 -8 -7 -6=. 1=0 2=.25 3=.5 4=.75 5=1
gen deserve=resent_deserve
recode deserve -9 -8 -7 -6=. 1=0 2=.25 3=.5 4=.75 5=1
gen harder=resent_try
recode harder -9 -8 -7 -6=. 1=1 2=.75 3=.5 4=.25 5=0
gen sracism=(favors + slavery + deserve + harder)/4
label var sracism "Racial Resentment Scale"
tab sracism


*Party Identification (1=More Democratic)
gen party=.
replace party=6 if pid_self==1 & pid_strong==1
replace party=5 if pid_self==1 & pid_strong==2
replace party=4 if pid_lean==3
replace party=3 if pid_lean==2 | pid_lean==-8
replace party=2 if pid_lean==1
replace party=1 if pid_self==2 & pid_strong==2
replace party=0 if pid_self==2 & pid_strong==1
gen party2=(party/6)
label var party2 "7-point Party Variable 0-1 with Dem=1"
tab party2

gen party3=party
recode party3 0/2=0 3=.5 4/6=1
label var party3 "3-point Party Variable 0-1 with Dem=1"
tab party3
	
*Ideology (1=more liberal)
tab libcpre_self
tab libcpre_choose
gen ideol=.
replace ideol=1 if libcpre_self==1
replace ideol=2 if libcpre_self==2
replace ideol=3 if libcpre_self==3
replace ideol=3 if libcpre_self==-8 & libcpre_choose==1
replace ideol=3 if libcpre_self==-2 & libcpre_choose==1
replace ideol=3 if libcpre_self==4 & libcpre_choose==1
replace ideol=3 if libcpre_self==-9 & libcpre_choose==1
replace ideol=4 if libcpre_self==4 & libcpre_choose==3
replace ideol=4 if libcpre_self==4 & libcpre_choose==-8
replace ideol=4 if libcpre_self==4 & libcpre_choose==-9
replace ideol=4 if libcpre_self==-8 & libcpre_choose==3
replace ideol=4 if libcpre_self==-2 & libcpre_choose==3
replace ideol=4 if libcpre_self==-9 & libcpre_choose==3
replace ideol=5 if libcpre_self==5
replace ideol=5 if libcpre_self==-8 & libcpre_choose==2
replace ideol=5 if libcpre_self==-2 & libcpre_choose==2
replace ideol=5 if libcpre_self==4 & libcpre_choose==2
replace ideol=5 if libcpre_self==-9 & libcpre_choose==2
replace ideol=6 if libcpre_self==6
replace ideol=7 if libcpre_self==7
tab ideol 
replace ideol=(ideol-1)/6
tab ideol
replace ideol=(0+1)-ideol
tab ideol 
gen ideo2=ideol
label var ideo2 "7-Point Ideological ID 0-1 with Lib=1"
tab ideo2

*Vote Choice 2012
gen howvote=presvote2012_x
recode howvote -9 -6 -2=. 1=1 2=0 5=.5
label var howvote "Respondent Presidential Vote Choice in 2012"
gen howvote2=howvote
recode howvote2 .5=.
label var howvote2 "Two-Party Vote for President in 2012"
tab howvote2

*Obama Rumors
gen born_outside=nonmain_born
recode born_outside -9 -8 -7 -6=. 4=3 3=2 2=1 1=0
label var born_outside "Obama was born outside of U.S.?"
tab born_outside

gen born_outside_recoded=born_outside
recode born_outside_recoded 0=0 1=.33 2=.67 3=1
label var born_outside_recoded "Support for Birther Rumor (0-1)"
tab born_outside_recoded

gen bo_muslim=candrel_dpc
recode bo_muslim -9=. -8=0 1/3=0 4=1 5/95=0
label var bo_muslim "R Selected Muslim as BO Religion"
tab bo_muslim

*Obama Administration Favors Blacks over Whites
gen presblk=nonmain_bias
recode presblk -9 -8 -7 -6=. 1=0 2=1 3=.5
label var presblk "Obama Administration favors Blacks over Whites"
tab presblk

*****Analyses (Table 4)

svy: ologit born_outside presblk female age educ2 income ownhome south polinfo sracism ideo2 if face2face==1 & white==1 & party3==0

svy: ologit born_outside presblk female age educ2 income ownhome south polinfo sracism ideo2 if face2face==1 & white==1 & party3==1

margins, at(presblk=1 female=1 south=0) atmeans predict (outcome(2))

margins, at(presblk=1 female=1 south=0) atmeans predict (outcome(3))


svy: logit bo_muslim presblk female age educ2 income ownhome south polinfo sracism ideo2 if face2face==1 & white==1 & party3==0

svy: logit bo_muslim presblk female age educ2 income ownhome south polinfo sracism ideo2 if face2face==1 & white==1 & party3==1

margins, at(presblk=(0(.5)1) female=1 south=0) atmeans


*****Analyses (Table 5)

svy: logit howvote2 born_outside_recoded female age educ2 income ownhome south sracism ideo2 if face2face==1 & white==1 & party3==0

svy: logit howvote2 born_outside_recoded female age educ2 income ownhome south sracism ideo2 if face2face==1 & white==1 & party3==1

margins, at(born_outside_recoded=(0(.33)1) female=1 south=0) atmeans


svy: logit howvote2 bo_muslim female age educ2 income ownhome south sracism ideo2 if face2face==1 & white==1 & party3==0

svy: logit howvote2 bo_muslim female age educ2 income ownhome south sracism ideo2 if face2face==1 & white==1 & party3==1

margins, at(bo_muslim=(0(1)1) female=1 south=0) atmeans





	
